package org.gr.ias.Investment.controller;

import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.gr.ias.Investment.service.InvestmentService;
import org.gr.ias.common.entity.CapitalInvestment;
import org.gr.ias.common.model.JqgridBean;
import org.gr.ias.common.model.PageRusult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 投资管理
 */
@Slf4j
@Controller
@RequestMapping(value = "/investment")
public class InvestmentController {

    @Resource
    private InvestmentService investmentService;

    private Logger log = LoggerFactory.getLogger(InvestmentController.class);

    /**
     * 跳转页面
     * @return
     */
    @RequestMapping("/investmentManage")
    public String toInvestmentManage(){
        return "power/investment";
    }

    /*
     *查询投资
     */
    @RequestMapping(value = "/selectInvestment")
    public Map<String, Object> selectInvestment(JqgridBean jqgridBean){
        Map<String,Object> map = new HashMap<>();
        log.info("开始查询投资列表");
        Example example = new Example(CapitalInvestment.class);
        PageHelper.offsetPage(jqgridBean.getPage(),jqgridBean.getLength());
        List<CapitalInvestment> capitalInvestments = investmentService.selectByExample(example);
        PageRusult<CapitalInvestment> pageRusult =new PageRusult<CapitalInvestment>(capitalInvestments);
        log.info("查询投资列表完毕");
        map.put("datamap",capitalInvestments);
        return map;
    }

    /**
     * 投资信息详情
     */
    @RequestMapping(value = "/investmentMsg")
    public Map<String, Object> investmentMsg(Integer id){
        Map<String,Object> map = new HashMap<>();
        log.info("开始查询投资信息详情");
        CapitalInvestment capitalInvestment = investmentService.selectByKey(id);
        log.info("查询投资信息详情完毕");
        map.put("capitalInvestment",capitalInvestment);
        return map;
    }

    /**
     * 审核投资
     */
    @RequestMapping(value = "/checkInvestment")
    public Map<String, Object> checkInvestment(){
        Map<String,Object> map = new HashMap<>();
        log.info("开始审核投资项目");
        log.info("审核投资项目完毕");
        return map;
    }

    /**
     * 锁定投资
     */
    @RequestMapping(value = "/lockInvestment")
    public Map<String, Object> lockInvestment(){
        Map<String,Object> map = new HashMap<>();
        log.info("开始锁定投资项目");
        log.info("投资融资项目完毕");
        return map;
    }

    /**
     * 加入黑名单
     */
    @RequestMapping(value = "/investmentAddBlack")
    public Map<String, Object> investmentAddBlack(){
        Map<String,Object> map = new HashMap<>();
        log.info("开始执行加入黑名单操作");
        log.info("执行加入黑名单操作完毕");
        return map;
    }
}
